pp108 : Embedding WS-AppServer Functionality in Applications

Embedding WS-AppServer Functionality in Applications

This topic describes the procedure to use WS-AppServer in embedded mode.

Before you begin this task:

  • Ensure that Process Platform is installed on your computer and all the required classes, jars, and external jars required for your application to work are available at the appropriate location on your computer.
  • Ensure that XmlForJava.dll, which is available as part of the Process Platform installation, is set in the path of system environment variable.

WS-AppServer's functionality in applications is primarily made available in the form of a Service. However, as an alternative, it is possible to leverage its functionality as an embedded server within an application's processing layer, without creating a WS-AppServer Service. In the absence of an external processor, these applications use WS-AppServer's functionality through Java APIs that are available in the SDK. These APIs help establish communication between the application and the configuration file containing WS-AppServer functionality.
WS-AppServer uses the XML Query (XQY) functionality provided by Process Platform to establish database connectivity. Therefore, to use WS-AppServer in embedded mode, you must install Process Platform.

  1. Create an XML file using the structure of the Bsfconfig file that is provided here (depending upon the type of database provider that you are using):

    Option

    Description

    If you are using OLEDB connector

    Use the structure of bsfconfig.xml with OLE DB attributes

    If you are using JDBC connector

    Use the structure of bsfconfig.xml with JDBC attributes

    Note:
    In the config file, you need to provide a Base-64 encoded value for the Password property.

  2. Place this file at a location of your choice.
  3. From <Process_Platform_Installation_Directory>\<instance name>\components\wsappserver\config, open the wsapps.properties file using a suitable text editor. The wsapps.properties file opens, displaying two attributes.
  4. Provide the path of the file containing WS-AppServer processor configuration details (that you created in Step 1) against the attribute wsappserver.default.config.file=, in the format as shown below. For example, in Windows, wsappserver.default.config.file= D\:<Process_Platform_Installation_Directory><instance name>bsfbsfconfig.xml and in Linux wsappserver.default.config.file= /opt/Cordys/ESB/bsf/bsfconfig.xml. In case of Windows, remember to place the "\" before ":" exactly as shown here for the reference to work. Note: WS-AppServer framework uses the value of this attribute to locate and read the WS-AppServer processor configuration details from the configuration file.
  5. Save the file and close it.
  6. Invoke the WS-AppServer client using the Java code.

WS-AppServer is configured to be used in embedded mode.

Tip
As an alternative, you can avoid creating the XML file and still configure WS-AppServer to function in an embedded mode. Insert the following sample code (containing configuration details) into the Java code that is used to invoke WS-AppServer:

package com.mycomp.myapp; import java.io.UnsupportedEncodingException; import com.cordys.cpc.bsf.busobject.BSF; import com.cordys.cpc.bsf.busobject.BsfContext; import com.cordys.cpc.bsf.busobject.Config; import com.eibus.xml.nom.Document; import com.eibus.xml.nom.XMLException; import com.cordys.cpc.bsf.busobject.exception.BsfRuntimeException; public class MyApp { private static Document m_oDocument = new Document(); private static BsfContext context; public static void initialize() { int iConfig = 0; try { iConfig = m_oDocument.parseString(" <configurations/>"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } catch (XMLException e) { e.printStackTrace(); } // configurations refers to the WS-AppServer configuration. Config wsAppConfig = new Config(); wsAppConfig.setConfig(iConfig); context = BSF.initBsfContext(); if (context == null) { throw new BsfRuntimeException("Context not initialized properly."); } } public static void main(String args[]) { // initialize context initialize(); // Write your application specific code here. BSF.unregisterContext(context); //To unregister the context that was initialized. } }

Subsequently, running the Java code would configure WS-AppServer to function in embedded mode.
For further information on the Java methods, refer WS-AppServer SDK.